CMAKE_MINIMUM_REQUIRED(VERSION 3.15)

## Enable O2 Optimization.
SET(CMAKE_CXX_FLAGS "-std=c++14 -O2")


## Announce the project name.
PROJECT("LearnPCL")
SET(PROJECT_NAME LearnPCL)
SET(LIBRARY_NAME PclShared)


## Specify work dirs.
SET(PROJECT_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)


## Find third party dependencies.
# PCL
FIND_PACKAGE(PCL REQUIRED)
INCLUDE_DIRECTORIES(${PCL_INCLUDE_DIRS})
LIST(REMOVE_ITEM PCL_LIBRARIES "vtkproj4") ## needed if install pcl from repo (and libproj-dev)
# libLAS
FIND_PACKAGE(libLAS REQUIRED)
INCLUDE_DIRECTORIES(${LIBLAS_INCLUDE_DIRS})
# VTK
FIND_PACKAGE(VTK REQUIRED)
INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})
# OpenCV
#FIND_PACKAGE(OpenCV REQUIRED)
#INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})


SET(THIRD_PARTY_LIBS ${PCL_LIBRARIES} ${libLAS_LIBRARIES} ${VTK_LIBRARIES} #${OpenCV_LIBS}
        )

IF(NOT WIN32)
    SET(SPECIAL_OS_LIBS "pthread" "X11")
    ADD_DEFINITIONS(-Wno-write-strings -fpermissive)
ENDIF()


## Our include directories.
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)


## Generate our own shared library.
FILE(GLOB_RECURSE SRC_FILES src/*.cpp)
LIST(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
FILE(GLOB_RECURSE HEAD_FILES include/*.h)
LIST(REMOVE_ITEM HEAD_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/main.h)

ADD_LIBRARY(PclShared SHARED ${SRC_FILES})
TARGET_LINK_LIBRARIES(PclShared ${THIRD_PARTY_LIBS})


## Specify executable source file.
ADD_EXECUTABLE(${PROJECT_NAME} src/main.cpp)


## Add all link directories to project.
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PclShared)